local lieshi = fk.CreateSkill{
  name = "lzsj__lieshi",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["lzsj__lieshi"] = "裂师",
  [":lzsj__lieshi"] = "锁定技，准备阶段或结束阶段，若你没有手牌，你摸两张牌并对已损失体力值最大的一名角色造成1点伤害。",
  ["#lzsj__lieshi-choose"] = "裂师：请选择已损失体力值最大的一名角色",

  ["$lzsj__lieshi1"] = "分兵劫敌辎重，十八路节度使互疑如仇寇！",
  ["$lzsj__lieshi2"] = "分兵不是溃逃，是让复仇的火种烧遍九州！",
}

lieshi:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(lieshi.name) and player:isKongcheng()
    and (player.phase == Player.Start or player.phase == Player.Finish)
  end,
  on_cost = function(self, event, target, player, data)
    local players = table.filter(player.room:getAlivePlayers(), function (p)
      return table.every(player.room:getAlivePlayers(), function (sp) return p:getLostHp() >= sp:getLostHp() end)
    end)
    if #players > 0 then
      local to = player.room:askToChoosePlayers(player, {
        skill_name = lieshi.name,
        targets = players,
        min_num = 1,
        max_num = 1,
        prompt = "#lzsj__lieshi-choose",
        cancelable = false,
      })
      if #to > 0 then
        event:setCostData(self, to[1])
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, lieshi.name)
    player.room:damage({
      from = player,
      to = event:getCostData(self),
      damage = 1,
      damageType = fk.NormalDamage,
      skillName = lieshi.name,
    })
  end,
})

return lieshi